def is_valid_brackets(sequence):
    stack = []
    brackets_map = {')': '(', ']': '[', '}': '{', '>': '<'}

    for bracket in sequence:
        if bracket in brackets_map.values():
            stack.append(bracket)
        elif bracket in brackets_map.keys():
            if stack and stack[-1] == brackets_map[bracket]:
                stack.pop()
            else:
                return False

    return not stack

# Пример использования:
bracket_sequence = input("Введите скобочную последовательность: ")
result = is_valid_brackets(bracket_sequence)
print(result)